{extend name="public/base" /}

{block name="title"}<title>{$Think.lang.list}</title>{/block}

{block name="pjax_container"}
<section class="content-header">
    <h1>{$Think.lang.c_title}</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title"></h3>
                    <div class="pull-left">
                        {:auth_action(CONTROLLER_NAME.'/create', 'a', lang('create'), '', 'primary', 'sm', 'save')} 
                    </div>
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover">
                        <tr>
                            <th>{$Think.lang.id}</th>
                            <th>{$Think.lang.name}</th>
                            <th>{$Think.lang.status}</th>
                            <th>{$Think.lang.sorts}</th>
                            <th width="255">{$Think.lang.action}</th>
                        </tr>
                        {volist name="dataList" id="vo"}
                        <tr>
                            <td>{$vo.id}</td>
                            <td>
                                {if $vo.h_layer eq 1 }
                                {else /}{for start="1" end="$vo.h_layer"}　　　{/for}├
                                {/if}
                                <span class="editable" data-pk="{$vo.id}" data-name="name" data-url="{:url(CONTROLLER_NAME.'/edit', 'id='.$vo['id'])}" >{$vo.name}</span>
                            </td>
                            <td>
                                <a href="javascript:void(0);" data-id="{$vo.id}" data-field="status" 
                                data-value="{$vo.status}" data-url="{:url('edit', 'id='.$vo['id'])}" 
                                class='editimg fa {if $vo.status == 1 }fa-check-circle text-green{else /}fa-times-circle text-red{/if}'></a>
                            </td>
                            <td><span class="editable" data-pk="{$vo.id}" data-name="sorts" data-url="{:url(CONTROLLER_NAME.'/edit', 'id='.$vo['id'])}" >{$vo.sorts}</span></td>
                            <td>
                                {include file="public/list_action" /}
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript">
$(function(){
    $('.editable').editable({
        emptytext: "empty",
        params: function(params) {      //参数
            var data = {};
            data['id'] = params.pk;
            data[params.name] = params.value;
            return data;
        },
        success: function(response, newValue) {
            var res = $.parseJSON( response );
            if(res.status == 1){
                toastr.success(res.info);
            }else{
                return res.info;
            }
        }
    });
})
</script>
{/block}